package com.scgl.process.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.scgl.process.domain.ScglLead;
import com.scgl.process.service.IScglLeadService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 领料信息Controller
 *
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/lead")
public class ScglLeadController extends BaseController
{
    @Autowired
    private IScglLeadService scglLeadService;

    /**
     * 查询领料信息列表
     */
    @RequiresPermissions("process:lead:list")
    @GetMapping("/list")
    public TableDataInfo list(ScglLead scglLead)
    {
        startPage();
        List<ScglLead> list = scglLeadService.selectScglLeadList(scglLead);
        return getDataTable(list);
    }

    /**
     * 导出领料信息列表
     */
    @RequiresPermissions("process:lead:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, ScglLead scglLead)
    {
        List<ScglLead> list = scglLeadService.selectScglLeadList(scglLead);
        ExcelUtil<ScglLead> util = new ExcelUtil<ScglLead>(ScglLead.class);
        util.exportExcel(response, list, "领料信息数据");
    }

    /**
     * 获取领料信息详细信息
     */
    @RequiresPermissions("process:lead:query")
    @GetMapping(value = "/{serial}")
    public AjaxResult getInfo(@PathVariable("serial") Long serial)
    {
        return success(scglLeadService.selectScglLeadBySerial(serial));
    }

    /**
     * 新增领料信息
     */
    @RequiresPermissions("process:lead:add")
    @Log(title = "领料信息新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ScglLead scglLead)
    {
        return toAjax(scglLeadService.insertScglLead(scglLead));
    }

    /**
     * 修改领料信息
     */
    @RequiresPermissions("process:lead:edit")
    @Log(title = "领料信息修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ScglLead scglLead)
    {
        return toAjax(scglLeadService.updateScglLead(scglLead));
    }

    /**
     * 删除领料信息
     */
    @RequiresPermissions("process:lead:remove")
    @Log(title = "领料信息删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{serials}")
    public AjaxResult remove(@PathVariable Long[] serials)
    {
        return toAjax(scglLeadService.deleteScglLeadBySerials(serials));
    }
}
